package com.qianfeng.openplatform.geteway.fiter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.exception.ZuulException;
import com.qianfeng.openplatform.geteway.bean.ESFieldBean;
import com.qianfeng.openplatform.geteway.rabbit.LogsListenProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.messaging.support.MessageBuilder;
import sun.security.krb5.internal.ccache.FileCCacheConstants;

/**
 * @author 江江
 * @Date 2020/7/30 14:05
 */
public class LogsFilter extends ZuulFilter {
    @Autowired
    private LogsListenProvider provider;

    @Override
    public String filterType() {
        return FilterConstants.PRE_TYPE;
    }

    @Override
    public int filterOrder() {
        return FilterConstants.PRE_DECORATION_FILTER_ORDER+20;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() throws ZuulException {
        ESFieldBean bean= new ESFieldBean();

        provider.output().send(MessageBuilder.withPayload(bean).build());

        return null;
    }
}
